package com.cnbot.printertest;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;

import com.cnbot.printer.IPrintListener;
import com.cnbot.printer.PrinterApi;

public class MainActivity extends AppCompatActivity implements IPrintListener {
    private final String TAG= MainActivity.class.getSimpleName();
    private PrinterApi printerApi;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);


    }

    private void initD(){
        printerApi = PrinterApi.getInstance(MainActivity.this);

        printerApi.setPrintDevice(this);
        printerApi.scanPrinterDevice();
    }

    public void OnPrintClick(View view) {
        initD();
       /* printerApi.printerText("我要我很快乐 快乐到心如刀割\n" +
                "\n" +
                "越痛越深刻越懂得\n" +
                "\n" +
                "什么值得 什么难舍 什么趁早不要了\n" +
                "\n" +
                "我要我很快乐 傻就要傻得透彻\n" +
                "\n" +
                "从今以后爱恨再拉扯\n" +
                "\n" +
                "孤独再苦涩 再也伤不了我的");*/
    }

    @Override
    public void deviceNotFound() {
        Log.e(TAG, "没有找到该打印机设备");
    }

    @Override
    public void connected() {
        Log.e(TAG, "连接成功");
    }

    @Override
    public void connecting() {
        Log.e(TAG, "正在连接");
    }

    @Override
    public void connectNone() {
        Log.e(TAG, "连接失败");
    }


    @Override
    protected void onDestroy() {
        super.onDestroy();

    }

    public void OnCloseClick(View view) {
        printerApi.disConnectDevice();
    }
}
